{
    input_df = iris[,1:2,drop = F]
    # input_df$Sepal.Length <- rnorm(nrow(input_df)),
    group_info_df = iris[,5,drop = F]
    group_index = 1
    group_levels_in_order_C = group_info_df[,1] %>% unique()
    test_pattern  = "para" 
    # test_pattern  = "wise" ,
    # test_pattern  = "non-para" %>% tolower(),
    p_for_label = "p_all"
    step = 0.15 # Modify the vertical distances between significant label codes.
    draw_pics = F
    position_by = "max meanse"
}


obj <- get_pic_with_labels(input_df = iris[,1:4],
                                # input_df$Sepal.Length <- rnorm(nrow(input_df)),
                                group_info_df = iris[,5,drop = F],
                                group_index = 1,
                                group_levels_in_order_C = group_info_df[,1] %>% unique(),
                                test_pattern  = "para" ,
                                # test_pattern  = "wise" ,
                                # test_pattern  = "non-para" %>% tolower(),
                                p_for_label = "p_all",
                                step = 0.05,
                                draw_pics = F, 
                                position_by = "max single value")

cat(obj@demo_code_for_barplot)



obj <- get_pic_with_labels(input_df = iris[,1:4,drop = F],
                           # input_df$Sepal.Length <- rnorm(nrow(input_df)),
                           group_info_df = iris[,5,drop = F],
                           group_index = 1,
                           group_levels_in_order_C = group_info_df[,1] %>% unique(),
                           test_pattern  = 'para' ,
                           # test_pattern  = 'wise' ,
                           # test_pattern  = 'non-para' %>% tolower(),
                           p_for_label = 'p_all',
                           step = 0.15, # Modify the vertical distances between significant label codes.
                           draw_pics = F, 
                           position_by = 'max meanse')


variables_c <- obj@pic_long_df$variable %>% unique
page_num <- variables_c %>% length
segment_size <- .7 ## The size of the segement
# each_page <- 1
# obj@pic_long_df
# for(each_page in 1:page_num){

# each_meta <- variables_c[each_page]
obj@pic_long_df %>% head
pic <- ggplot(obj@pic_long_df) + 
    ## error bar by mean ± se
    geom_errorbar( aes(x= group, ymin=mean-se, ymax=mean+se),  
                   width=0.4, colour='black', alpha=0.9, size=1.3) +
    geom_bar(aes(x = group, y = mean, group = group, fill = group), data = obj@pic_long_df , 
             # size  = .8,
             position = position_dodge(),
             stat='identity'
             # outlier.colour = 'white',
             # width = 2,
             
    )+
    theme_bw()+
    facet_wrap(facets = vars(variable), nrow = 1, scales = 'fixed')+
    theme(
        text = element_text(size = 18, color = 'black'),
        axis.text.y = element_text( size = 12, face = 'bold', color = 'black'),
        axis.text.x = element_text( size = 12, face = 'bold', color = 'black'),
        strip.text.x = element_text(size = 16, color = 'black'),
        panel.grid = element_blank()
    )
pic
pic <- pic +
    geom_segment(data = obj@label_position_df,
                 aes(x = start_num, xend = start_num + 0.25 * (end_num - start_num),
                     y = label.y, yend = label.y), lineend = 'butt', size = segment_size)+
    geom_segment(data = obj@label_position_df, 
                 aes(x = end_num, xend = start_num + 0.75 * (end_num - start_num),
                     y = label.y, yend = label.y), 
                 lineend = 'butt', size = segment_size)+
    geom_text(data = obj@label_position_df, 
              aes(x = 0.5*(start_num + end_num), y = label.y*1.007, label = label)
              ,color = 'black', size = 8) +
    geom_segment(data = obj@label_position_df, aes(x = start_num, xend = start_num, y = label.y, yend = label.y * .99), lineend = 'round', size = segment_size)+
    geom_segment(data = obj@label_position_df, aes(x = end_num, xend = end_num, y = label.y, yend = label.y * .99), lineend = 'round', size = segment_size)+
    geom_segment(data = obj@label_position_df, aes(x = start_num, xend = end_num, y = label.y, yend = label.y),
                 size = segment_size) + 
    xlab('Group')+
    ylab('Concentration (μmol/L)')+
    scale_y_continuous(expand = expansion(c(0.05,0.05)))
pic

plot_name <- sprintf('%splot with sig labels #%s.pdf', output_path, each_meta)

ggsave(plot_name, plot = pic, width = 5, height = 4, 
       limitsize = F, family = 'serif')




df <- data.frame(x = rep(c(2.9, 3.1, 4.5), c(5, 10, 4)))
ggplot(df, aes(x)) + geom_bar()